package com.ycsj.goldmedalnewconcept.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.bean.RgInfo;
import com.ycsj.goldmedalnewconcept.utils.Validator;

import java.util.List;

//import base.CommonAdapter;
//import base.ViewHolder;
//import family.Validator;

/**
 * 创建日期：2017/11/8  9:15
 * 描述:红包列表展示的适配器
 * 作者:张伟
 */

public class RpListLvAdapter extends CommonAdapter<RgInfo.RedPacketBean> {
    private Context context;

    public RpListLvAdapter(Context context, List<RgInfo.RedPacketBean> datas, int layoutId) {
        super(context, datas, layoutId);
        this.context = context;
    }

    @Override
    public void convert(ViewHolder holder, final RgInfo.RedPacketBean info) {
        //显示金钱的相对布局
        RelativeLayout rlMoney = holder.getView(R.id.rl_money);

        //显示金钱的TextView
        TextView tvMoney = holder.getView(R.id.tv_money);

        //显示名称的TextView
        TextView tvName = holder.getView(R.id.tv_name);

        //显示红包编号的TextView
        TextView tvNo = holder.getView(R.id.tv_no);

        //显示到期时间的TextView
        TextView tvTime = holder.getView(R.id.tv_time);

        //显示领取人手机号的TextView
        TextView tvTel = holder.getView(R.id.tv_tel);

        //右边的整体线性布局
        LinearLayout llRight = holder.getView(R.id.ll_right);

        //是否使用的标记
        ImageView lvFlag = holder.getView(R.id.lv_flag);

        if ("1".equals(info.getStatus())) {
            //表示没有用过红包
            rlMoney.setBackgroundResource(R.drawable.red_nouse);
            llRight.setBackgroundResource(R.drawable.redpack_bg);
            lvFlag.setVisibility(View.GONE);
        } else if ("2".equals(info.getStatus())) {
            //表示用过红包
            rlMoney.setBackgroundResource(R.drawable.red_haduse);
            llRight.setBackgroundResource(R.drawable.redpack_bg);
            lvFlag.setVisibility(View.VISIBLE);
        }
        //设置数据
        tvMoney.setText("￥ " + info.getMoney());
        tvName.setText(info.getSchool());
        tvNo.setText("红包编号:" + info.getId());
        tvTime.setText(Validator.getDate(info.getExpirationDay()) + "到期");
        tvTel.setText("领取人手机号" + info.getCustomer());

    }
}
